package com.hy.main.demo.img;

import org.springframework.web.multipart.MultipartFile;

import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @Author yang DongYong
 * @Date 2022/4/27 - 04 - 27 - 3:40
 * @Description: com.hy.main.demo.img
 * @version: 1.0
 */
public class ImgDemo {
    /**
     * 获取上传图片
     * @param file
     * @return
     */

    public static BufferedImage inputImage(MultipartFile file) {
        BufferedImage srcImage = null;
        try {
            FileInputStream in = (FileInputStream) file.getInputStream();
            srcImage = javax.imageio.ImageIO.read(in);
        } catch (IOException e) {
            System.out.println("读取图片文件出错！" + e.getMessage());
        }
        return srcImage;
    }
}
